package com.rjyb.student_management_platform;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Weekly {
    public static void main(String[] args) {

        Calendar c = Calendar.getInstance();

        int dayofweek = c.get(Calendar.DAY_OF_WEEK) -1;

        if (dayofweek == 0)

            dayofweek = 7;

        c.add(Calendar.DATE, -dayofweek + 1);

        // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        int r = Integer.parseInt(new SimpleDateFormat("dd").format(c.getTime()));
        int n = Integer.parseInt(new SimpleDateFormat("yyyy").format(c.getTime()));
        int y = Integer.parseInt(new SimpleDateFormat("MM").format(c.getTime()));
        List<String> list = new ArrayList<String>();
        for (int i = 1; i <= 7; i++) {
            String date = n+"-"+y+"-"+r+"";
            r++;
            if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
                if(r>31){
                    r = 1;
                    y = y(y);
                }
            }else if(y==2){
                if((n % 4 == 0 && n % 100 != 0) || n %400 == 0){
                    if(r>29){
                        r = 1;
                        y = y(y);
                    }
                }else {
                    if(r>28){
                        r = 1;
                        y = y(y);
                    }
                }
            }else if(y == 4 || y == 6||y==9||y==11){
                if(r>30){
                    r = 1;
                    y = y(y);
                }
            }
            list.add(date);
        }
        for (String s : list) {
            System.out.println(s);
        }
    }
    public static int y(int y){
        if(y<12){
            y++;
        }else {
            y = 1;
        }
        return y;
    }
}
